/*    
 * Copyright (c) 2013 ISoftStone, Inc.
 * All right reserved.
 *
 * 文件名：      BillServiceImpl.java
 * 作者:     Jacky Wang
 * 创建日期： 2013-7-29 下午03:42:22
 * 版本：           
 *
 */
package com.isoftstone.industry.aaa.core.service.assist.impl;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.isoftstone.industry.persistance.bean.Bill;
import com.isoftstone.industry.aaa.core.dao.assist.BillDao;
import com.isoftstone.industry.aaa.core.service.assist.IBillService;
import com.isoftstone.modules.core.persistence.IGenericDao;
import com.isoftstone.modules.core.service.impl.GenericServiceImpl;

/**
 *
 * @author jacky
 */
@Service
public class BillServiceImpl extends GenericServiceImpl<Bill, String> implements IBillService
{
	@Resource
	private BillDao billDao;
	
	@Override
	public IGenericDao<Bill, String> getDao()
	{
		return billDao;
	}

	@Override
	public Bill findByUserAndBillingCycle(String userId, String cycleId)
	{
		return billDao.findByUserAndCycle(userId, cycleId);
	}

	@Override
	public void markMailDelivered(String billId, Timestamp deliverTime)
	{
		billDao.updateDeliverStatus(billId, Bill.DeliverStatus.DELIVERED, deliverTime);
	}

	@Override
	public List<Bill> findPayableBill(String userId)
	{
		return billDao.findByUserAndPayableGreaterThan0(userId);
	}

	@Override
	public boolean hasBillByUserAndBillingCycle(String userId, String cycleId) {
		long count = billDao.countByUserAndCycle(userId, cycleId);
		return count != 0;
	}

}
